<template>
  <div class="main">
    <ul class="ul_info">
      <li><label>姓名</label><span>{{utils.replaceName(data.aac003)}}</span></li>
      <li><label>身份证号</label><span>{{utils.replaceCard(data.aac002)}}</span></li>
    </ul>
    <ul class="ul_info ul_top">
      <li><label>单位名称</label><input type="text" v-model="data.aab004" placeholder="请输入单位名称"/></li>
      <li><label>单位编号</label><input type="text" v-model="data.aab001" placeholder="请输入单位编号"/></li>
      <li><label>联系电话</label><input type="tel" maxlength="11" v-model="data.mobile" placeholder="请输入联系电话"/></li>
      <li><label>通讯地址</label><input type="text" v-model="data.aae006" placeholder="请输入通讯地址"/></li>
      <li><label>邮政编码</label><input type="tel" maxlength="6" v-model="data.aae007" placeholder="请输入邮政编码"/></li>
    </ul>
    <div class="btn_save" @click="setData">保存</div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        data: {},
        userInfo: this.utils.getUser()
      }
    },
    created () {
      this.getData();
    },
    methods: {
      //获取社保信息
      getData(){
        this.$http.post("transmit",{
          "access_token":this.utils.getToken(),
          "transmitUrl": "/ssCardMgr/cardInfoQuery",
          "method": "get",
          "objectId": "f4860abe5e8e49eca2725360f0c65c6c",
          "objectType": "1"
        }).then(res => {
          console.log(res)
          if (res.success) {
            this.data = res.body;
          }
        });
      },
      setData(){
        let tel="";
        if (!this.data.aab004) {
          this.$toast({
            message: "请输入单位名称",
            duration: 3000
          });
          return false;
        }
        if (!this.data.aab001) {
          this.$toast({
            message: "请输入单位编号",
            duration: 3000
          });
          return false;
        }
        if (!this.data.mobile) {
          this.$toast({
            message: "请填写联系电话",
            duration: 3000
          });
          return false;
        }
        if(this.data.mobile.indexOf("*")==-1){
        if (!this.utils.isPhone(this.data.mobile)) {
          this.$toast({
            message: "请填写正确格式联系电话",
            duration: 3000
          });
          return false;
        }else {
          tel=this.data.mobile;
        }
        }
        if (!this.data.aae006) {
          this.$toast({
            message: "请输入通讯地址",
            duration: 3000
          });
          return false;
        }
        if (!this.data.aae007) {
          this.$toast({
            message: "请输入邮政编码",
            duration: 3000
          });
          return false;
        }
        let xmldata ="<操作*>人员信息修改</操作*><用户名*>411400ZHRS</用户名*><密码*>411400ZHIhrsApp</密码*><证件号码*>"+this.userInfo.certnum
          +"</证件号码*><姓名*>"+this.userInfo.name+"</姓名*><移动电话>"+tel
          +"</移动电话><通讯地址>"+this.data.aae006+"</通讯地址><邮政编码>"+this.data.aae007+"</邮政编码><单位名称>"+this.data.aab004+"</单位名称><单位编号>"+this.data.aab001+"</单位编号>";
        this.$http.post("transmit",{
          transmitUrl: "ssCardMgr/personInfoEdit",
          access_token:this.utils.getToken(),
          method: "post",
          aac002: this.userInfo.name,
          aac003: this.userInfo.certnum,
          mobile: tel,
          aae006: this.data.aae006,
          aae007: this.data.aae007,
          objectId: "70e4d43830694d6bb523e775a2451c74",
          objectType: "1",
          inputParamXml: xmldata
        }).then(res => {
          console.log(res)
        });
      },
    }
  }
</script>

<style lang="less" scoped>
  .ul_info {
    background: #ffffff;
    li {
      padding-right: 4%;
      margin-left: 4%;
      border-bottom: 1px solid #DFDFDF;
      overflow: hidden;
      line-height: 0.45rem;
    }
    li:last-child {
      border-bottom: none;
    }

    label {
      display: inline-block;
    }

    span {
      color: #888888;
      float: right;
      max-width: 70%;
    }

    input {
      border: none;
      outline: none;
      line-height: 0.45rem;
      float: right;
      text-align: right;
      width: 70%;
    }
  }

  li {
    list-style: none;
    text-align: left;
    line-height: 23px;
    font-size: 13px;
  }

  .ul_top {
    margin-top: 0.1rem;
  }

  .btn_save {
    width: 90%;
    height: 0.48rem;
    background: #3399FF;
    font-size: 0.18rem;
    color: #FFFFFF;
    text-align: center;
    line-height: 0.48rem;
    margin: 0.35rem auto;
    border-radius: 0.05rem
  }
</style>
